function [ X ] = GetWorldPoint( F,a1,s1,s2)
global A;
	a1 = deg2rad(a1);
	
	%calculate pixel at the first image
	e1 = null(F);
    point1 = e1(1:2)./e1(3) + s1*[cos(a1) sin(a1)]';

    P1 = [eye(3) [0 0 0]'];

	epiLine = F*[point1;1];
    a2 = atan(-epiLine(1)/epiLine(2));
    
    %calculate pixel at the second image
    e2 = null(F');
	point2 = e2(1:2)./e2(3) + s2*[cos(a2) sin(a2)]';
    
    
    
	P2 = [[  0 -e2(3) e2(2);
                e2(3) 0 -e2(1);
                -e2(2) e2(1) 0] * F  e2 ];
            

    %we want to calculate X s.t x = XP and x'=XP' when x,P related
	%to the first image and camera and x',P' to the second ones.
	%it comes to minimize the equasion AX = 0 when A is:
    A = [   point1(1) .* P1(3,:) - P1(1,:);
                point1(2) .* P1(3,:) - P1(2,:);
                point2(1) .* P2(3,:) - P2(1,:);
                point2(2) .* P2(3,:) - P2(2,:)];

    
	%get the initial guess from the SVD decomposition
    [U D V] = svd(A);
    init_guess = V(:,end);
	%solve the eq.
    X=lsqnonlin(@geom_dist,init_guess);
end

function F=geom_dist(X)
global A;
	%return an estimation of how AX far from 0
	comp_A=A*X;
	F=sqrt(sum(comp_A.*comp_A));
end